<template>
  <div class="basic-setting-content pl16 pr16">
    <!--基本信息-->
    <div class="common-form">资质证书</div>
    <el-form-item label="检验报告：" :rules="[{ required: false, message: '请上传检验报告图片' }]" prop="model.verify_report">
      <div class="draggable-list">
        <div v-if="form.model.verify_report" class="item">
              <ImagePreview :src="form.model.verify_report" width="100px" height="100px" />
              
            </div>
        
      </div>
    </el-form-item>
    <!-- <el-form-item label="生产许可证：" :rules="[{ required: true, message: '请上传生产许可证图片' }]" prop="model.product_license">
      <div class="draggable-list">
        <div v-if="form.model.product_license" class="item">
              <ImagePreview :src="form.model.product_license" width="100px" height="100px" />
            </div>
      </div>
    </el-form-item>
    <el-form-item label="标准号：" :rules="[{ required: true, message: '请上传标准号图片' }]" prop="model.standard_no">
      <div class="draggable-list">
        <div v-if="form.model.standard_no" class="item">
              <ImagePreview :src="form.model.standard_no" width="100px" height="100px" />
              
            </div>
       
      </div>
    </el-form-item>
    <el-form-item label="产品登记证：" :rules="[{ required: true, message: '请上传产品登记证图片' }]" prop="model.product_registration">
      <div class="draggable-list">
        <div v-if="form.model.product_registration" class="item">
          <ImagePreview :src="form.model.product_registration" width="100px" height="100px" />
            </div>
      </div>
    </el-form-item> -->
    <!--商品图片组件-->
    <Upload v-if="isProductUpload" :config="{ total: 1 }" :isupload="isProductUpload" @returnImgs="returnProductImgsFunc">上传图片</Upload>
  </div>
</template>

<script>

import Upload from '@/components/file/Upload';
import ImagePreview from '@/components/ImagePreview/index';
import draggable from 'vuedraggable';
export default {
  components: {
    Upload,
    ImagePreview,
    draggable
  },
  data() {
    return {
      isProductUpload: false,
      key:''
    };
  },
  inject: ['form'],
  created() {

  },
  methods: {

    /*打开上传图片*/
    openProductUpload: function(key) {
      this.key = key;
      this.isProductUpload = true;
    },

    /*上传商品图片*/
    returnProductImgsFunc(e) {
      if (e != null) {
        let imgs = e[0].file_path;
        this.$set(this.form.model, this.key, imgs);
      }
      this.isProductUpload = false;
    },

    /*删除商品图片*/
    deleteImg(key) {
      this.$set(this.form.model, key, '');
    }
  }
};
</script>

<style>
.edit_container {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  line-height: 20px;
  color: #2c3e50;
}

.ql-editor {
  height: 400px;
}

.draggable-list {
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
}
.draggable-list .wrapper > span {
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.draggable-list .item {
  position: relative;
  width: 110px;
  height: 110px;
  margin-top: 10px;
  margin-right: 10px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #dddddd;
}

.draggable-list .delete-btn {
  position: absolute;
  top: 0;
  right: 0;
  width: 16px;
  height: 16px;
  background: red;
  line-height: 16px;
  font-size: 16px;
  color: #ffffff;
  display: none;
}

.draggable-list .item:hover .delete-btn {
  display: block;
}

.draggable-list .item img {
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  max-height: 100%;
  max-width: 100%;
}

.draggable-list .img-select {
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px dashed #dddddd;
  font-size: 30px;
}

.draggable-list .img-select i {
  color: #409eff;
}
</style>
